The file weight_chart.txt contains data for a growth chart for a typical baby over the first 9 months of its life.
data = read.table("data/weight_chart.txt", header=T)
Here is the plot:
plot(data$Age, data$Weight,
xlab="Age (months)", ylab="Weight (kg)", ylim=c(2,10),
pch=15, cex=1.5, lwd=2, type="o",
main="Baby Weight with Age")
The file feature_counts.txt contains a summary of the number of features of different types in the mouse GRCm38 genome.
data = read.table("data/feature_counts.txt", header=T, sep="\t")
Here is the plot:
## The margins should be adjusted to accommodate the labels
## (below, left, above, right)
par(mar=c(c(3.1, 11.1, 4.1, 2)))
barplot(data$Count, names.arg=data$Feature,
xlim=c(0,80000),
las=1, horiz=T,
main="Number of features in the mouse GRCm38 genome")
The x variable takes the distribution of 10000 points sampled from a standard normal distribution along with another 10000 points sampled from the same distribution but with an offset of 4.
set.seed(1)
data = c(rnorm(10000), rnorm(10000)+4)
Here is the plot:
hist(data, breaks=80)
The file male_female_counts.txt contains a time series split into male and female count values.
data = read.table("data/male_female_counts.txt", header=T, sep="\t")
Here is the plot for rainbow color:
barplot(data$Count, names.arg=data$Sample,
las=2,
col=rainbow(nrow(data)))
Here is the plot for alternating red and blue:
barplot(data$Count, names.arg=data$Sample,
las=2,
col=c("red","blue"))
The file up_down_expression.txt contains an expression comparison dataset, and an extra column which classifies the rows into one of 3 groups (up, down or unchanging).
data = read.table("data/up_down_expression.txt", header=T, sep="\t")
table(data$State)
##
## down unchanging up
## 72 4997 127
Here is the plot by classification of up/down regulated expression:
plot(data$Condition1, data$Condition2,
xlab="Expression condition 1", ylab="Expression condition 2",
col=data$State)
Here is the plot by specifying the color for each classification:
palette(c("blue","gray","red"))
plot(data$Condition1, data$Condition2,
xlab="Expression condition 1", ylab="Expression condition 2",
col=data$State)
The file expression_methylation.txt contains data for gene body methylation, promoter methylation and gene expression.
data = read.table("data/expression_methylation.txt", header=T, sep="\t")
Here is the plot (expresion vs gene regulation):
plot(data$gene.meth, data$expression)
One common use of dynamic color is to color a scatterplot by the number of points overlaid in a particular area so that you can get a better impression for where the majority of points fall.
Here is the plot (expresion vs gene regulation) with density and points of solid circles:
dcols = densCols(data$gene.meth, data$expression)
plot(data$gene.meth, data$expression,
col=dcols, pch=20)
It looks like most of the data is clustered near the origin. Let’s restrict ourselves to the genes that have more than zero expresion values.
inds = data$expression > 0
dcols = densCols(data$gene.meth[inds], data$expression[inds])
plot(data$gene.meth[inds], data$expression[inds],
col=dcols, pch=20)
Here is the plot (expresion vs gene regulation) with density, points of solid circles and customized colors:
dcols = densCols(data$gene.meth[inds], data$expression[inds],
colramp=colorRampPalette(c("blue2", "green2", "red2", "yellow")))
plot(data$gene.meth[inds], data$expression[inds],
col=dcols, pch=20)
The file, again, expression_methylation.txt contains data for gene body methylation, promoter methylation and gene expression.
data = read.table("data/expression_methylation.txt", header=T, sep="\t")
Here is the plot (promoter regulation vs gene regulation):
plot(data$promoter.meth, data$gene.meth)
Here is the plot (promoter regulation vs gene regulation) after adding color based on expression level:
source("data/color_to_value_map.r")
mycols=map.colors(data$expression,
c(max(data$expression), min(data$expression)),
colorRampPalette(c("blue","red"))(100))
plot(data$promoter.meth, data$gene.meth,
xlab="Promoter Methylation", ylab="Gene Methylation",
col=mycols)
plot(1:10,typ="l",col="blue")
read.table("data/test1.txt", header=T, sep=",")
## Col1 Col2 Col3
## 1 1 2 3
## 2 4 5 6
## 3 7 8 9
## 4 a b c
read.table("data/test2.txt", header=T, sep="$")
## Col1 Col2 Col3
## 1 1 2 3
## 2 4 5 6
## 3 7 8 9
## 4 a b c
read.table("https://bioboot.github.io/bimm143_S19/class-material/test3.txt")
## V1 V2 V3
## 1 1 6 a
## 2 2 7 b
## 3 3 8 c
## 4 4 9 d
## 5 5 10 e